Improving the efficiency of using multivalued logic tools

Multivalued logics are becoming one of the most important tools of information technology. They are in great demand for creation of artificial intelligence systems that are close to human intelligence, since the functioning of the latter cannot be reduced to the operations of binary logic. At the same time, the problem of improving the efficiency of using the results of research in multivalued logics, as well as the problem of interpreting variables of multivalued logic, is acute. These problems create certain interdisciplinary barriers and make it difficult to implement the results of research in the field of multivalued logics in other fields of knowledge. It is shown that the problem of interpreting multivalued logic variables can be removed by establishing correspondence with fuzzy logic variables. Improving the efficiency of using of operations of multivalued logics and their variables can be provided by using their close connection to Galois fields. This connection, among other things, makes it possible to reduce any operations of multivalued logics, the number of variables in which is equal to a prime number, to algebraic functions whose arguments take values in Galois fields. This allows, among other things, to eliminate the very cumbersome constructions used in works on multivalued logic and make its apparatus convenient for use in related scientific disciplines in information technology. Direct verification of the adequacy of algorithms based on the use of Galois fields can be carried out by means of radio-electronic circuits, examples of which are presented in the present paper.


Scientific Reports
| (2023) 13:1108 | https://doi.org/10.1038/s41598-023-28272-1 www.nature.com/scientificreports/ within binary logic, its variables can be uniquely associated with the notion of truth, such uniqueness is lost for multivalued logics, which determines the relevance of research in the philosophy of multivalued logics, which is currently being actively pursued 11,12 . However, we must admit that a full-fledged return to the tradition that considers logic as a reflection of the laws of thinking, obviously, cannot be realized otherwise than on an interdisciplinary basis. This, in turn, requires overcoming pronounced interdisciplinary barriers. The language in which the works on multivalued logics are written remains difficult to comprehend for a large part of specialists in other fields of knowledge, in particular in information technologies.
A definite step towards overcoming the interdisciplinary barriers is knowingly solving the problem of visibility of variables of multivalued logics touched upon in 13,14 .
To solve this problem, it is reasonable to use the correspondence between multivalued logics and algebraic structures, such as Galois fields, which are widely used in modern information technologies, especially in cryptography [15][16][17] . This correspondence can be most easily established when the number of variables of a particular multivalued logic is equal to the degree of the prime number p. In this case, a Galois field element GF(p n ) can be assigned to each value of a variable of multivalued logic in a one-to-one correspondence.
For Galois fields, in turn, the following illustrative interpretation can be proposed. As emphasized 18,19 , the standard model of a signal is a function taking values on a set of real numbers. However, in the case when the signal is reduced to a certain set of discrete levels that fit into a finite range of amplitude measurements, this approach is not mandatory. A function taking values in any finite algebraic structure, such as Galois fields, can also be used as a signal model. The simplest kind of Galois fields GF(p) is formed through a homomorphism of a ring of integers to a ring of classes of deductions modulo p , where p is a prime number.
In this paper, we show that the problem of interpreting the variables of multivalued logic can be solved, for example, by establishing a correspondence between the variables of multivalued logic and the variables of fuzzy logic. Variables of multivalued logic can also be assigned to the levels of the digitized signal in the case when the signal model is a function that takes values in Galois fields. More broadly, the variables of multivalued logic can be interpreted through the establishment of links between concepts (e.g., philosophical categories). In all these cases, it is important to have a tool that allows you to bring logical relationships to an algebraic form. For the case when the set of variables of multivalued logic can be assigned to the field GF(p n ) , this problem is solved through an analogue of the algebraic normal form presented in this paper.
Section 1 shows that the use of multivalued logic variables can be made explicit, including by mapping to multivalued logic variables.
Section "Visualization of the variables of multivalued logic" shows that for the case when the number of variables is equal to a prime number, instead of the truth tables traditionally used in works on multivalued logic, it is also possible to use an analog of the algebraic normal form (the Zhegalkin polynomial).
Section "Reduction of multivalued logic operations to algebraic ones" provides a specific example showing that multivalued logic operations can be performed using electronic devices built on typical binary logic components.

Visualization of the variables of multivalued logic
Clear illustrations for the practical use of variables of multivalued logics are easiest to offer, focusing on the approaches used in fuzzy logic. As is known, fuzzy logic establishes a certain correspondence between ranges of continuously varying parameters and linguistic variables marking them 20 . Simplifying, the apparatus of linguistic variables allows to "transform into words" the values of parameters, which, under certain conditions, can be quantitatively measured with high accuracy.
It is interesting to note that linguistic variables were introduced in practice long before fuzzy logic was created. For example, in maritime, there has traditionally been a set of commands "full astern, … slow astern, …, slow ahead, …, full ahead." A similar conclusion is also valid in relation to the compass rose ( Fig. 1), which is also traditionally used in maritime affairs. Figure 1 emphasizes that the 8-element compass rose can be used to visually interpret the variables of 9-digit logic.
The variables of such a logic can be put in correspondence with elements of the Galois field GF(3 2 ) , which, in turn, can be constructed as an algebraic extension of the field GF(3).
Recall that the method of algebraic extensions can be viewed as a generalization of the method by which complex numbers are constructed. Let us demonstrate the fact on a simple example of the construction of the field GF(3 2 ).
The field GF(3) contains three elements. They can be chosen as (−1, 0, 1) by setting the following addition rules.
According to the method of algebraic extensions, an additional element θ , which is the root of an equation irreducible (having no solutions) in this field, is attached to this (or any other) field.
where f (x) is a polynomial of degree n, x is a variable that takes values in GF (3).
In the special case where n = 2 such irreducible equation is the equation that allows one to construct complex numbers www.nature.com/scientificreports/ Then the element θ can be treated as a logical imaginary unit, and the elements of the field GF(3 2 ) can be represented as where variables a 0 , a 1 belong to the main field.
In this case, we can perform algebraic operations with elements of the form (4) according to formulas (1) and (3). For example, The rules of multiplication remain the same as in the classical use of complex numbers, in particular, The elements of this field are listed in Table 1. In general, any element of the field GF(3 n ) can be represented as a linear combination of powers of θ.
where θ is a primitive element, a j are coefficients from the main field of GF(3) , and n is the degree of the polynomial f (x) generating the element θ.
The field GF(3 2 ) contains eight non-zero elements (Table 1). Using the notation (4) as a logical coordinate representation, these eight elements can be assigned to the directions of compass roses, which is shown in Fig. 1.
In this example there is a one-to-one correspondence between the elements of multivalued logic, linguistic variables, and elements of the Galois field. More precisely, the elements of the compass rose allow all the above interpretations, which are in a mutually unambiguous correspondence.
Thus, the problem of interpreting multivalued logic variables can be removed if these variables are interpreted through correspondence to fuzzy logic variables. Such an approach, as shown in Section "Reduction of (4) A = a 0 + ia 1 ,    www.nature.com/scientificreports/ multivalued logic operations to algebraic ones", is generalizable. Namely, in this interpretation, rather a wide range of different terms (including philosophical categories) can be used instead of fuzzy logic variables. Obviously, it is not the specific set of sounds or symbols that represent them that gives meaning to natural language words, but the fact that each of these words is built into the overall structure of the language. Therefore, the meaning of terms is actually determined by the connections between them. The "True-False" opposition, which forms the methodological basis of binary logic, is only the simplest form of such a connection. Let us show that for the case when the number of variables of multivalued logic is equal to a prime number, any operations in such logic can be reduced to operations of addition and multiplication in the Galois field.

Reduction of multivalued logic operations to algebraic ones
The operations of multivalued logic are usually displayed in the form of truth tables. So, the following Table 2 are reflecting the operations of the logic of paradoxes by G. Priest 21 .
In these tables, symbols "0", "1" and "2" are denoting logical variables. The interpretation of the variables of ternary logic as "Truth", "False", "Uncertainly" dates back to the works of Lukasiewicz. The interpretation of such operations (disjunction, conjunction, negation, etc.) as applied to ternary logic can be different, likewise, the use of specific symbols in such tables is nothing more than a matter of agreement.
Such a tabular representation is not always convenient. Operations on logical variables, to which elements of the Galois field are assigned, can be reduced to algebraic ones. For clarity, this can be done, for example, as follows.
To avoid cluttering the notes, we will consider the case of an arbitrary function f (x, y) , taking values in the field GF(p) , where x, y are elements of the same Galois field. This function corresponds to a truth table given by an ordered enumeration of elements f ( Consider the following expression where x i is a fixed element of the field GF(p). It is known from Galois field theory that all nonzero elements of the field GF(p) are roots of the equation That is, any nonzero element of the field GF(p) , if raised to the p − 1 st power, gives one. Consequently, the functions g i (x) have the following property This allows us to treat them as a logical analogue of the δ-function. Let us form the following polynomial where the values f (x i , y j ) form a truth table like the Table 2.
When a particular pair of x i 0 , y j 0 values of logical variables (or more exactly, their corresponding Galois field elements) is substituted into expression (11), all summands appearing in the sum in the right part of formula (11) turn to zero because of relation (8) except the summand for which i = i 0 , j = j 0 is satisfied. Hence, it follows that We see that the polynomial (11) performs the same functions for multivalued logic as the Zhegalkin polynomial for binary logic, i.e., relation (11) indicates a specific algebraic function which realizes a given truth table.
It is also seen that relation (11) admits a generalization to the case of an arbitrary number of logical variables.  www.nature.com/scientificreports/ Note that control methods based on fuzzy logic are currently being actively developed 22,23 . There are known works, in which such methods are proposed to be used for correcting the course of ships 24 .
Obviously, if a one-to-one correspondence is established between linguistic variables and Galois field elements, then all "commands" and "data" transformed to such variables can be further processed using algebraic functions, which can be constructed knowingly by the method described above.
Of course, for real problems, the number of variables corresponding to an 8-element compass rose is insufficient, but this is not an obstacle.
The elements of this field are also representable in the "two-coordinate" form (4), where the coefficients a 0 , a 1 belong to the field GF (7).
The entry (4) in this case, for clarity, can be interpreted, for example, as a discrete representation of the velocity vector (in the plane), which fully corresponds to the traditional complex representation of vectors. The difference is that using the field GF(7 2 ) , the velocity components are discrete, and they can be assigned to seven linguistic variables "full astern, half astern, small astern, stop engine, small ahead, half ahead, full ahead".
The use of such a field also allows us to map the linguistic variables corresponding to the 16-item compass rose, Fig. 2.
Namely, the number of non-zero elements of the field GF(7 2 ) is 48. Consequently, they are all roots of the equation Formula (13), among other things, shows that among the elements of the field GF(7 2 ) there are 16 elements that satisfy the equation These 16 elements can be viewed as roots of the 16th degree from one, and they form a group by multiplication. Consequently, they can be assigned linguistic variables corresponding to the 16-element compass rose.
Thus, the mutually unique correspondence between multivalued p n -logics, where p is prime number, n is integer and Galois fields GF(p n ) creates all preconditions for making operations on variables of multivalued logic as clear as possible.
It can be argued that visualization in this respect is provided not so much for variables of multivalued logic as for elements of Galois fields. However, the visual representation of operations on the variables of multivalued logic mapped through Galois fields has also a philosophical aspect directly related to the problem of interpretation of the values of the mentioned variables and to the problem of correlation of laws of thinking and multivalued logics touched upon in 8 . www.nature.com/scientificreports/ Namely, the meaning of the variables of binary logic relates to the philosophical category of truth. This category belongs to the number of basic concepts, the question about the nature of which is closely related to the problem of the existence of undefined concepts. Indeed, to "define" means to reveal the meaning of one term through others. Trying to reveal all the terms available in a language in this way leads knowingly to a vicious circle.
Objective dialectics finds a way out by defining the basic categories through the oppositions "quantity-quality," "content-form," etc. Such an approach, in particular, was used 13,25 in order to reveal as correctly as possible, the meaning of the category "information", which it was suggested to consider as a philosophical category paired with the category of matter.
The problem of adequate interpretation of the concept "information" as emphasized in 26,27 becomes more and more relevant in connection with the research in the field of artificial intelligence, but for the purposes of our article the approach of "definition through contraposition" itself is more important.
Namely, it shows that for the definition of basic notions the most important is the structure of relations between them, and contraposition is only one of the forms of such relations, and the one that knowingly corresponds to binary logic and Galois binary fields. Obviously, other forms of connections between basic concepts cannot be reduced to a simple contraposition.
This indicates for example the existence of a pronounced methodological (philosophical) aspect of the development of command languages (even at the level of specific technical systems), which constitute a closed whole at the expense of relations written in algebraic form. Moreover, it is extremely difficult to develop closed "language" systems at the level of abstraction. It is much more convenient (and illustrative) to do this by solving specific problems, for example, those related to control of moving vehicles, in terms of fuzzy logic converted into algebraic form.
This formulation of the question makes it even more urgent to ensure the visibility and usability of multivalued logics. The following section deals with specific computational tools oriented to the use of logics corresponding to the fields GF(7 n ).
This example allows you to clearly demonstrate that it is possible to implement various kinds of devices that perform calculations in terms of multivalued logic, but at the same time built on the basis of typical electronic components using binary logic.

Computational implementation of seven-digit logic operations
Currently, algorithms and schemes of radioelectronic devices that perform calculations modulo are widely represented in the literature. Thus, such algorithms are used in encryption, coding devices, in compression and transmission of information, in automation devices [28][29][30] .
As shown above, any functions whose arguments are variables taking values in the Galois field can be explicitly reduced to algebraic expressions which involve only multiplication and addition operations modulo p.
Consequently, multipliers and adders modulo p are the basis for automating any operations on logical (linguistic) variables. Devices of this type can be implemented by rather simple means, as it is proved below.
The block diagram of the multiplier of the considered type is presented in Fig. 3. The scheme includes adders (marking on the scheme is ), which count the number of units on the inputs a i corresponding to the number representation in binary form. It is supposed, that on the input of the system no signals corresponding to number 7 or number 0 are input. This is acceptable, since when calculating modulo 7, 7 ≡ 0(7) takes place, therefore, in this case, the calculated product is equal to zero. In this case a i can take values 1 or 2, as in the binary notation of numbers that vary from 1 to 6, there are at least one and at most two units. Then where a i are characters in the binary notation of the number, a bar over the character means the inversion operation, i.e., 0 changes to 1 and vice versa. Due to the associativity of multiplication modulo, the product of any two non-zero elements of the field GF(7) can be reduced to the multiplication of two numbers in binary representation, and in both of these numbers only one of the symbols a i will be non-zero.
Correspondent operation is realized by the inverter block (the standard inverter designation is used in the scheme) controlled by the signal taken from elements. If logical zero is formed on the output of these elements, signals a i and b i remain unchanged, if logical one, they take inverse values.
The signal sets a i and b i , reduced to a format in which only one of the variables of these sets is non-zero, are fed to the direct multiplier block (schematic designation-⊗).
The signal set c i from the output of the direct multiplier is fed to the output inverter block, which operates in the same way as the input inverter block.
The schematic diagram of the direct multiplication block is shown in Fig. 4. This block works as follows. The prime number 7 is a special case of prime Mersenne numbers, represented in the form p m = 2 n − 1 . Such numbers have the following property. Multiplication of any number by 2 modulo p m results is a cyclic permutation of symbols. For example, where a i are binary characters.
Let us consider the product of two numbers B · A written in binary notation. We have (15) 6 · a 3 a 2 a 1 = (7) a 3 a 2 a 1 (16) 2 · a 2 a 1 a 0 = (7) a 1 a 0 a 2 www.nature.com/scientificreports/ According to formula (16), products 2 m · A may be written through cyclic permutations, i.e. the product calculated modulo 7, is the sum of the following three numbers written in binary form as where only one of the b i values is 1, and the rest are 0.
Each of the binary three-digit numbers appearing in formulas (18) Therefore, the result of the product corresponds to the three outputs of the circuit, on which the logical variables c i are formed.
Since of all the values b i only one is equal to 1, then three options are possible. A scheme that provides such a permutation can be implemented in various ways. One of them is based on a set of operations, which can be represented schematically as follows.
These notations imply that the NO and OR operations are applied to each of the boolean variables appearing in the sequences. Formulas (28) and (29) show only a particular case; they obviously remain valid for cyclic permutations as well.
From these formulas it follows that the permutation corresponding to formulas (25)- (27) can also be implemented in the way that is implemented by the scheme of Fig. 4. www.nature.com/scientificreports/ In this case, if b 1 = 0 , an additional inversion of the signal is performed, which corresponds to the execution of operation (28). According to the diagram in Fig. 4 this operation is performed by the adder, the output of which is connected to the output inverter.
The complete scheme, made in the NI Multisim application 31 , is shown in Fig. 5. As follows from the above description of the multiplier, its scheme takes into account the most important specific features of computational systems carrying out operations in Galois fields, which are directly connected with operations of multivalued logic.

Conclusion
This paper shows that the problem of interpreting the variables of multivalued logic does not necessarily have to be solved through the involvement of the philosophical category of truth. A possible option is to use a close connection between the variables of multivalued logics, whose number of elements is equal to the degree of a prime number, with Galois fields. In this case it is possible, among other things, to establish a connection between the variables of multivalued logic and the linguistic variables used in fuzzy logic. In addition, this relationship allows to reduce any operations on variables of multivalued logic to the calculation of algebraic functions whose arguments take a value in the Galois field. Otherwise, any operations of multivalued logics of the specified type can be reduced to the operations of addition and multiplication modulo the degree of a prime number.
Such operations, in their turn, can be realized by means of radio electronic circuits assembled on typical elements, performing operations of binary logic. At the same time, as shown in the example of implementation of such circuits, they can be quite simple.

Data availability
All data generated or analysed during this study are included in this published article. www.nature.com/scientificreports/